package cn.hfjava.kz.common.enums;

import java.util.stream.Stream;

public enum NongYeEnum {
    //是否农业户口(0:表示否 1:表示是否）

    YES(1, "是"), NO(0, "否");
    ;

    private String label;
    private Integer value;

    NongYeEnum(Integer value, String label) {
        this.value = value;
        this.label = label;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public static NongYeEnum convert(Integer value) {
        //2.使用Stream API实现
        NongYeEnum nye = Stream.of(NongYeEnum.values())
                .filter(e -> e.getValue().equals(value)).findFirst().orElse(null);
        return nye;
    }

    public static NongYeEnum convert(String label) {
        //2.使用Stream API实现
        NongYeEnum nye = Stream.of(NongYeEnum.values())
                .filter(e -> e.getLabel().equals(label)).findFirst().orElse(null);
        return nye;
    }
}
